import java.util.Scanner;

//题目：输入一行字符，分别统计出其中英文字母、空格、数字和其它字符的个数。
public class Test07 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入字符串");
        String r = scanner.nextLine();
        int english = 0, numb = 0, space = 0, other = 0, i = 0;
        char arr;
        for (i = 0; i < r.length(); i++) {
            arr = r.charAt(i);
//            System.out.print(arr);
            if (arr == ' ') {
                space++;
            } else if ((arr >= 'a' && arr <= 'z') || (arr >= 'A' && arr <= 'Z')) {
                english++;
            } else if (arr >= '0' && arr <= '9') {
                numb++;
            } else {
                other++;
            }
        }
        scanner.close();
        System.out.println("英文字符有" + english + "个,数字有" + numb + "个,空格有" + space + "个,其他字符有" + other + "个。");
    }
}
